package main

import (
	"encoding/gob"
	"strings"
	"wjp/models"
	_ "wjp/routers"
	"github.com/astaxie/beego"
	_ "wjp/models"
)

func main() {
	initSession()
	initTemplate()
	beego.Run()
}

func initSession(){
	//beego的session序列号是用gob的方式，因此需要将注册models.User
	gob.Register(models.User{})
	beego.BConfig.WebConfig.Session.SessionOn=true
	beego.BConfig.WebConfig.Session.SessionName="wjp"
	beego.BConfig.WebConfig.Session.SessionProvider="file"
	beego.BConfig.WebConfig.Session.SessionProviderConfig="./data/sessioin"
}

func initTemplate(){

	beego.AddFuncMap("equrl", func(x,y string) bool {
			x1 :=strings.Trim(x,"/")
			y1 :=strings.Trim(y,"/")

			return  strings.Compare(x1,y1)==0
	})

	beego.AddFuncMap("add", func(x,y int) int {
		return  x+y
	})
}

